<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
</style>

<script>
	import {
		mapMutations
	} from 'vuex';
	import uniPopup from 'components/uni-popup/uni-popup.vue';
	import shareBtn from 'components/share-btn/share-btn.vue';
	export default {
		onLaunch: function() {
			plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
				uni.showModal({ //提醒用户更新  
					title: "更新版本1.0.1",
					content: "版本说明",
					success: (res) => {
						console.log(res);
					}
				});
				console.log(widgetInfo);
			});
			uni.getStorage({
				key: 'uerInfo',
				success: (res) => {
					uni.request({
						url:`${this.$serverUrl}/check_token`,
						header: {
							"Content-Type": "application/json"
						},
						data: {
							"token": res.data.token
						},
						method: "GET",
						success: (e) => {
							if(e.data.status == 200){
								this.login(res.data);
							}else{
								uni.navigateTo({
									url:'pages/login/login'
								})
							}
						},
						fail: (e) => {
							this.$toast_fail("请求失败");
						}
					})
				},
				fail: () => {
					this.logout();
				}
			});
			uni.getClipboardData({
				success(res) {
					uni.setStorage({
						key:'spread_data',
						data:res.data
					})
				}
			});
		},
		methods: {
			...mapMutations(['login','logout'])
		}
	};
</script>

<style>

</style>
